<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Module      :  Data.Tuple</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2001</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-9"></span><span class="hs-comment">--</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Functions associated with the tuple data types.</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Tuple</span><span>
</span><span id="line-19"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Data.Tuple.html#fst"><span class="hs-identifier">fst</span></a></span><span>
</span><span id="line-20"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Tuple.html#snd"><span class="hs-identifier">snd</span></a></span><span>
</span><span id="line-21"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Tuple.html#curry"><span class="hs-identifier">curry</span></a></span><span>
</span><span id="line-22"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Tuple.html#uncurry"><span class="hs-identifier">uncurry</span></a></span><span>
</span><span id="line-23"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Tuple.html#swap"><span class="hs-identifier">swap</span></a></span><span>
</span><span id="line-24"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>      </span><span class="hs-comment">-- Note [Depend on GHC.Tuple]</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">default</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>              </span><span class="hs-comment">-- Double isn't available yet</span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-31"></span><span class="hs-comment">-- Standard functions over tuples</span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-comment">-- | Extract the first component of a pair.</span><span>
</span><span id="line-34"></span><span id="local-6989586621679533577"><span id="local-6989586621679533578"><span class="annot"><a href="Data.Tuple.html#fst"><span class="hs-identifier hs-type">fst</span></a></span><span>                     </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679533578"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679533577"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679533578"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-35"></span><span id="fst"><span class="annot"><span class="annottext">fst :: forall a b. (a, b) -&gt; a
</span><a href="Data.Tuple.html#fst"><span class="hs-identifier hs-var hs-var">fst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679533551"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679533551"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679533551"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-comment">-- | Extract the second component of a pair.</span><span>
</span><span id="line-38"></span><span id="local-6989586621679533573"><span id="local-6989586621679533574"><span class="annot"><a href="Data.Tuple.html#snd"><span class="hs-identifier hs-type">snd</span></a></span><span>                     </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679533574"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679533573"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679533573"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-39"></span><span id="snd"><span class="annot"><span class="annottext">snd :: forall a b. (a, b) -&gt; b
</span><a href="Data.Tuple.html#snd"><span class="hs-identifier hs-var hs-var">snd</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679533550"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679533550"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">)</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679533550"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="hs-comment">-- | 'curry' converts an uncurried function to a curried function.</span><span>
</span><span id="line-42"></span><span class="hs-comment">--</span><span>
</span><span id="line-43"></span><span class="hs-comment">-- ==== __Examples__</span><span>
</span><span id="line-44"></span><span class="hs-comment">--</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- &gt;&gt;&gt; curry fst 1 2</span><span>
</span><span id="line-46"></span><span class="hs-comment">-- 1</span><span>
</span><span id="line-47"></span><span id="local-6989586621679533568"><span id="local-6989586621679533569"><span id="local-6989586621679533570"><span class="annot"><a href="Data.Tuple.html#curry"><span class="hs-identifier hs-type">curry</span></a></span><span>                   </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679533570"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679533569"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679533568"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679533570"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679533569"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679533568"><span class="hs-identifier hs-type">c</span></a></span></span></span></span><span>
</span><span id="line-48"></span><span id="curry"><span class="annot"><span class="annottext">curry :: forall a b c. ((a, b) -&gt; c) -&gt; a -&gt; b -&gt; c
</span><a href="Data.Tuple.html#curry"><span class="hs-identifier hs-var hs-var">curry</span></a></span></span><span> </span><span id="local-6989586621679533549"><span class="annot"><span class="annottext">(a, b) -&gt; c
</span><a href="#local-6989586621679533549"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679533548"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679533548"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679533547"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679533547"><span class="hs-identifier hs-var">y</span></a></span></span><span>             </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">(a, b) -&gt; c
</span><a href="#local-6989586621679533549"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679533548"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679533547"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-comment">-- | 'uncurry' converts a curried function to a function on pairs.</span><span>
</span><span id="line-51"></span><span class="hs-comment">--</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- ==== __Examples__</span><span>
</span><span id="line-53"></span><span class="hs-comment">--</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- &gt;&gt;&gt; uncurry (+) (1,2)</span><span>
</span><span id="line-55"></span><span class="hs-comment">-- 3</span><span>
</span><span id="line-56"></span><span class="hs-comment">--</span><span>
</span><span id="line-57"></span><span class="hs-comment">-- &gt;&gt;&gt; uncurry ($) (show, 1)</span><span>
</span><span id="line-58"></span><span class="hs-comment">-- &quot;1&quot;</span><span>
</span><span id="line-59"></span><span class="hs-comment">--</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- &gt;&gt;&gt; map (uncurry max) [(1,2), (3,4), (6,8)]</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- [2,4,8]</span><span>
</span><span id="line-62"></span><span id="local-6989586621679533562"><span id="local-6989586621679533563"><span id="local-6989586621679533564"><span class="annot"><a href="Data.Tuple.html#uncurry"><span class="hs-identifier hs-type">uncurry</span></a></span><span>                 </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679533564"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679533563"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679533562"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679533564"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679533563"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679533562"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span></span></span></span><span>
</span><span id="line-63"></span><span id="uncurry"><span class="annot"><span class="annottext">uncurry :: forall a b c. (a -&gt; b -&gt; c) -&gt; (a, b) -&gt; c
</span><a href="Data.Tuple.html#uncurry"><span class="hs-identifier hs-var hs-var">uncurry</span></a></span></span><span> </span><span id="local-6989586621679533546"><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621679533546"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679533545"><span class="annot"><span class="annottext">(a, b)
</span><a href="#local-6989586621679533545"><span class="hs-identifier hs-var">p</span></a></span></span><span>             </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">a -&gt; b -&gt; c
</span><a href="#local-6989586621679533546"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a, b) -&gt; a
forall a b. (a, b) -&gt; a
</span><a href="Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(a, b)
</span><a href="#local-6989586621679533545"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a, b) -&gt; b
forall a b. (a, b) -&gt; b
</span><a href="Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">(a, b)
</span><a href="#local-6989586621679533545"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-comment">-- | Swap the components of a pair.</span><span>
</span><span id="line-66"></span><span id="local-6989586621679533557"><span id="local-6989586621679533558"><span class="annot"><a href="Data.Tuple.html#swap"><span class="hs-identifier hs-type">swap</span></a></span><span>                    </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679533558"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679533557"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679533557"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679533558"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span></span><span>
</span><span id="line-67"></span><span id="swap"><span class="annot"><span class="annottext">swap :: forall a b. (a, b) -&gt; (b, a)
</span><a href="Data.Tuple.html#swap"><span class="hs-identifier hs-var hs-var">swap</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679533544"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679533544"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679533543"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679533543"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679533543"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679533544"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-comment">-- $setup</span><span>
</span><span id="line-70"></span><span class="hs-comment">-- &gt;&gt;&gt; import Prelude hiding (curry, uncurry, fst, snd)</span><span>
</span><span id="line-71"></span></pre></body></html>